package com.egao.orderB.service.impl;

import cn.hutool.core.util.StrUtil;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.AddressFactoryBiz;
import com.egao.orderB.entity.AddressFactory;
import com.egao.orderB.service.AddressFactoryService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import com.egao.orderB.mapper.AddressFactoryMapper;
//import javax.transaction.Transactional;

/**
 * 工厂地址服务实现类
 * @author : Doman
 * @date : 2020-08-07 09:56:44
 * @version ：1.0
 */
@Service
public class AddressFactoryServiceImpl /*extends ServiceImpl<AddressFactoryMapper, AddressFactory> */implements AddressFactoryService {

	@Autowired
	private AddressFactoryBiz addressFactoryBiz;

    /**
    @Override
    public PageResult<AddressFactory> listPage(PageParam<AddressFactory> page) {
        List<AddressFactory> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<AddressFactory> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */
    @Override
    public JsonResult list(PageResult2<T> page, AddressFactory addressFactory, User loginUser)  throws Exception{
        return addressFactoryBiz.list(page,addressFactory,loginUser);
    }

    @Override
    public JsonResult list(AddressFactory addressFactory, User loginUser) {
        return JsonResult.ok().setData(addressFactoryBiz.list(addressFactory,loginUser));
    }

    @Override
    public JsonResult getById(AddressFactory addressFactory) {
        return JsonResult.ok().setData(addressFactoryBiz.getById(addressFactory));
    }

    @Override
    public JsonResult save(AddressFactory addressFactory, User loginUser) {
        if (StrUtil.hasBlank(addressFactory.getCustomerId())) {
            return JsonResult.error("请填写完整,操作失败!");
        }
        return JsonResult.ok("添加成功").setData(addressFactoryBiz.save(addressFactory, loginUser));
    }

    @Override
    public JsonResult update(AddressFactory addressFactory, User loginUser) {
        if (StrUtil.hasBlank(addressFactory.getId())) {
            return JsonResult.error("请填写完整,操作失败!");
        }
        if (addressFactoryBiz.update(addressFactory, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult updateFstate(AddressFactory addressFactory, User loginUser) {
        if (StrUtil.hasBlank(addressFactory.getId(),addressFactory.getAddressId())) {
            return JsonResult.error("请填写完整,操作失败!");
        }
        if (addressFactoryBiz.updateFstate(addressFactory, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(AddressFactory addressFactory, User loginUser) {
        if (StrUtil.hasBlank(addressFactory.getId())) {
            return JsonResult.error("请填写完整,操作失败!");
        }
        if (addressFactoryBiz.remove(addressFactory, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
